package org.eclipse.epsilon.rdbms.core.Testing;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.eclipse.epsilon.emc.rdbms.core.imodel.DBReflexiveModelElement;
import org.eclipse.epsilon.emc.rdbms.core.persistancebroker.PersistanceBroker;



public class ConnectionTesting {

	public static void main(String[] args) throws SQLException 
	{
		//DBReflexiveModelElement element = new DBReflexiveModelElement("EPSILON_TEST_1"); //Create new Element for testing	
       // HashMap properties = new HashMap();
//		ArrayList columns = new ArrayList();
		//Test Insert Statement for new Blank Element
		
		//PersistanceObject dbtask_newblankElement = new PersistanceObject();		
		//dbtask_newblankElement.addNewElement(element, properties);
		
		//Test insert Statement for none blank element
		//PersistanceObject dbtask_newnoneblankElement = new PersistanceObject();		
		//If an invalid property is found should we display a error message or simple just ignore it like we are currently doing.
		//properties.put("FORENAME", "Phillip");		
		//properties.put("SURNAME", "Birchall");
		//dbtask_newnoneblankElement.addNewElement(element, properties);
		
	
		//Now lets test the select mechanism for an element
		//PersistanceObject dbtaskselectElementAllCols = new PersistanceObject();	
		//ResultSet testget1AllCols = dbtaskselectElementAllCols.getElement(element, columns);
		//columns.add("CUSTOMERID");
		//columns.add("FORENAME");
		//ResultSet testget1MultiCols = dbtaskselectElementAllCols.getElement(element, columns);
		
		
		//while (testget1MultiCols.next())
		//{
		//System.out.println(testget1MultiCols.getString(1));
		//System.out.println(testget1MultiCols.getString(2));
		//System.out.println(testget1MultiCols.getString(3));
		//System.out.println(testget1MultiCols.getString(4));
		//System.out.println(testget1MultiCols.getString(5));
		//}
		
		//properties.clear();
		//properties.put("FORENAME", "STUART");
		
		//PersistanceObject dbtaskUpdateElement= new PersistanceObject();	
	    //ResultSet testUpdate1 = dbtaskUpdateElement.updateElement(element, properties);
		//while (testUpdate1.next())
		//{
		//System.out.println(testUpdate1.getString(1));
		//System.out.println(testUpdate1.getString(2));
		//System.out.println(testUpdate1.getString(3));
		//System.out.println(testUpdate1.getString(4));
		//System.out.println(testUpdate1.getString(5));
		//}
				
		//ResultSet testget1Record = dbtaskselectElementAllCols.getElement(element, null);
		//ResultSet testupdateRecord = dbtaskselectElementAllCols.updateElement(element, null);

		//Now test the delete functionality
		//String testdelete = dbtask.deleteElement(element);
		//System.out.println(testdelete);
	
		PersistanceBroker db_config= new PersistanceBroker();	
		ResultSet test = null;
		db_config.connectTo().getDbProperties();		
		test = db_config.connectTo().getSQLTables("ORDERS");
	    test.last();
	    System.out.println(test.getRow());
	    db_config.connectTo().db_setup("C:\\config.sql");
	    test = db_config.connectTo().getSQLTables("ORDERS");
	   test.last();
	    System.out.println(test.getRow());
	    //DBReflexiveModelElement element1 = new DBReflexiveModelElement("CUSTOMER"); //Create new Element for testing
		//DBReflexiveModelElement element2 = new DBReflexiveModelElement("ADDRESS"); //Create new Element for testing
		//db_config.retrieveFromTypeWithJoins(element1, element2);	
	}
}
